<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<!--头-->
<div th:replace="~{admin/examples/commons::head}"></div>

<body >
  <div class="wrapper ">
    <!--导航栏-->
    <div th:replace="~{admin/examples/commons::sidebar(active='user')}"></div>

    <div class="main-panel">
      <!-- Navbar -->
      <div th:replace="~{admin/examples/commons::navbar}"></div>
      <!-- End Navbar -->
      <div class="content">
        <div class="row">
          <div class="col-md-12">
            <div class="card" style="height: 500px;">
              <div class="card-header">
                <h4 class="card-title">用户管理</h4>
              </div>
              <div class="card-body">
                <div class="table-responsive">
                  <table class="table">
                    <thead class=" text-primary">
                    <th>
                      ID
                    </th>
                    <th>
                      名字
                    </th>
                    <th>
                      邮箱
                    </th>
                    <th>
                      角色
                    </th>
                    <th class="text-right">
                      操作
                    </th>
                    </thead>
                    <tbody>
                    <tr th:each="user:*{userpage.getList()}">
                      <td th:text="*{user.user_id}">
                        ID
                      </td>
                      <td th:text="*{user.user_name}">
<!--                        <a th:href="@{'https://www.baidu.com/'}"-->
<!--                           th:text="*{user.user_name}">名字-->
<!--                        </a>-->
                      </td>
                      <td th:text="*{user.user_email}">
                        邮箱
                      </td>
                      <td th:text="*{user.user_role}">
                        角色
                      </td>
                      <td class="text-right">
                        <button type="button" class="btn btn-danger"
                                th:onclick = "delUser([[${user.user_id}]])">删除
                        </button>
                      </td>
                    </tr>
                    </tbody>
                  </table>
                </div>
              </div>
              <nav aria-label="Page navigation example">
                <span  class="justify-content-center"></span>
                <ul class="pagination justify-content-center" >
                  <li class="page-item">
                    <a class="page-link" aria-label="Previous"
                       th:text="'现在是第  '+${userpage.getPageNum()}+'  页！'">
                      当前页码
                    </a>
                  </li>
                </ul>
                <ul class="pagination justify-content-center" >
                  <li class="page-item">
                    <a class="page-link" aria-label="Previous"
                       th:if = "${userpage.isHasPreviousPage()}"
                       th:href="@{'/user/userpage?setPageNum='+${userpage.getPrePage()}}">
                      <span aria-hidden="true">&laquo;</span>
                    </a>
                  </li>
                  <!--                      th:text="*{page}"-->
                  <!--                      <div th:each="page:*{userpage.getNavigatepageNums()}">-->
                  <ul class="pagination justify-content-center" th:each="page:*{userpage.getNavigatepageNums()}">
                    <li class="page-item">
                      <a class="page-link" th:href="@{'/user/userpage?setPageNum='+${page}}" th:text="*{page}">1</a>
                    </li>
                  </ul>
                  <li class="page-item">
                    <a class="page-link" aria-label="Next"
                       th:if = "${userpage.isHasNextPage()}"
                       th:href="@{'/user/userpage?setPageNum='+${userpage.getNextPage()}}">
                      <span aria-hidden="true">&raquo;</span>
                    </a>
                  </li>
                </ul>
              </nav>
            </div>
          </div>
        </div>
      </div>

      <!--底部-->
      <div th:replace="~{admin/examples/commons::footer}"></div>
    </div>



  </div>
  <!--   Core JS Files   -->
  <div th:replace="~{admin/examples/commons::script}"></div>
</body>

<script>
  function delUser(id){
    if (confirm("确定要删除???")) {
        console.log(id);
        window.location.href = "/user/deleteuser?id="+id;
      // window.location.reload();
    } else {

    }
  }

</script>
</html>